/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utilities;

import javax.microedition.rms.RecordStore;

/**
 *
 * @author Huy
 */
public class TrainingUtilities {

    public double calc_BMR(boolean Gender, double Weight, double Height, int Age) {
        if (Gender) {
            return (66 + (13.7 * Weight) + (5 * Height) - (6.8 * Age));
        } else {
            return (655 + (9.6 * Weight) + (1.8 * Height) - (4.7 * Age));
        }
    }

    public double calc_BMI(double Weight, double Height) {
        return Weight / (Height * Height) * 10000;
    }

    public String BMI_Status(double BMI) {
        if (BMI < 18) {
            return "hơi gầy";
        } else if (BMI >= 25) {
            return "hơi béo";
        } else {
            return "bình thường";
        }
    }

    public double calc_CalorieBurn(double BMR, double MET, double Time) {
        return (BMR / 24) * MET * Time/60;
    }

    public double calc_CalorieNeed(int Weightmode, double BMR) {
        if (Weightmode == -1) {
            return BMR * 1.3 + 500;
        } else if (Weightmode == 0) {
            return BMR * 1.3;
        } else {
            return BMR * 1.3 - 500;
        }
    }

    public String[] getActivities(double[] activities_mode,double BMR, double NeedToBurn) {
        String[] activities = new String[3];
        int time = 0;
        int i=0;
        while(i!=3){
            double calorieBurn0 = (BMR / 24) * activities_mode[0] * time/60;
            double calorieBurn1 = (BMR / 24) * activities_mode[1] * time/60;
            double calorieBurn2 = (BMR / 24) * activities_mode[2] * time/60;
            
            if(calorieBurn0 > NeedToBurn && activities[0] == null){
                activities[0] = "đi bộ trong thời gian " + time + " phút";
                i++;
            }
                
            if(calorieBurn1 > NeedToBurn && activities[1] == null){
                activities[1] = "chạy trong thời gian " + time + " phút";
                i++;
            }
            
            if(calorieBurn2 > NeedToBurn && activities[2] == null){
                activities[2] = "đi xe đạp trong thời gian " + time + " phút";
                i++;
            }
            time++;
        }
        
        return activities;
    }
}
